import re

# re 模块

s='123python123python456python567python999'

# match函数 从下标0开始查找匹配，并且只匹配一次，匹配不到则返回None
# result = re.match('python',s)
# print(result)
# print(result.group())
# print(result.span())

# search 值匹配一次，不是必须从下标0开始查找
# result1= re.search('python',s)
# print(result1) # <re.Match object; span=(3, 9), match='python'>
# print(result1.group()) # python
# print(result1.span()) # (3, 9)

# findall 查找多个字串，返回list多个匹配项
result3= re.findall('python',s)
print(result3)

# 全字符串匹配，和字符串相等比较判断完全一样。匹配相等
res = re.fullmatch('python',s)
print(res)

# 返回的是迭代器对象，如果匹配的结果很多，建议使用
res1 = re.finditer('python',s)
print(res1)
r1 = res1.__next__()
print(r1.group())
print(r1.span())
